package com.ccntec.spark.core.tags.form.date;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import com.ccntec.spark.core.BasicTagSupport;

public class DateDefaultTag extends BasicTagSupport {
	
	private String name ;
	private String id ;
	private String fromat ;
	private Integer width ;
	private boolean autoClose ; //自动关闭
	
	@Override
	public int doStartTag() throws JspException {
		
		StringBuffer html = new StringBuffer();
		StringBuffer style= new StringBuffer();
		style.append("style=\"");
		if(!isNull(width+"") && width>0){
			style.append("width:"+width+"px;");
		}
		style.append("\"");
		html.append("<div class=\"form-group\">\n");
		html.append("<div class=\"input-group date datepicker\" "+style+" ");
		if(autoClose){
			html.append("data-date-autoclose=\"true\" ");
		}
		if(!isNull(fromat)){
			html.append("data-date-format=\""+fromat+"\" >");
		}else{
			html.append("data-date-format=\"dd-mm-yyyy\" >");
		}
		html.append("<input class=\"form-control\" name=\""+name+"\" id=\""+id+"\" type=\"text\">");
		html.append("<span class=\"input-group-addon\"><i class=\"icon-calendar\"></i></span></input>\n");
		html.append("</div>\n</div>\n");
		outPrint(html);
		return EVAL_BODY_INCLUDE;
	}
	
	@Override
	public int doEndTag() throws JspException {
		return EVAL_PAGE;
	}
	
	@Override
	public void release() {
		// TODO Auto-generated method stub
		super.release();
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setFromat(String fromat) {
		this.fromat = fromat;
	}

	public void setAutoClose(boolean autoClose) {
		this.autoClose = autoClose;
	}
	public void setWidth(Integer width) {
		this.width = width;
	}
	
	
	

}
